package exp2;

import java.util.*;

public class T1_2 {
    public static void printLots(LinkedList<Integer> L, LinkedList<Integer> P) {
        for (int i = 0; i < P.size(); i++) {
            System.out.print(L.get(P.get(i) - 1) + " ");
        }
    }
    public static void main(String[] args) {
        LinkedList<Integer> L = new LinkedList<>();
        LinkedList<Integer> P = new LinkedList<>();
        Scanner sc = new Scanner(System.in);
        System.out.print("P: ");
        String[] str;
        str = sc.nextLine().split(",");
        for(int i = 0; i < str.length; i++) {
            L.add(Integer.parseInt(str[i]));
        }
        System.out.print("L: ");
        str = sc.nextLine().split(",");
        for(int i = 0; i < str.length; i++) {
            P.add(Integer.parseInt(str[i]));
        }
        printLots(L,P);
    }
}
